package com.geovis.emergency.spd.biz.zwdd.handler;

import cn.hutool.core.util.StrUtil;

/**
 * <p>
 * 事件枚举类
 * </p>
 *
 * @author 王响
 * @since 2022-03-17
 */
public enum EventEnum {

    /**
     * 增加/更新组织
     */
    ORGANIZATION_ADD_UPDATE("MOZI_VDS_TENANT_CHANGE|ORGANIZATION_ADD_UPDATE", "增加/更新组织", "deptAddUpdate", true),

    /**
     * 组织变更父组织
     */
    ORGANIZATION_PARENT_CHANGED("MOZI_VDS_TENANT_CHANGE|ORGANIZATION_PARENT_CHANGED", "组织变更父组织", "deptParentChange", true),

    /**
     * 删除组织
     */
    ORGANIZATION_REMOVE("MOZI_VDS_TENANT_CHANGE|ORGANIZATION_REMOVE", "删除组织", "deptRemove", true),

    /**
     * 增加/更新员工
     */
    EMPLOYEE_ADD_UPDATE("MOZI_VDS_TENANT_CHANGE|EMPLOYEE_ADD_UPDATE", "增加/更新员工", "employeeAddUpdate", true),

    /**
     * 删除员工
     */
    EMPLOYEE_LEAVE("MOZI_VDS_TENANT_CHANGE|EMPLOYEE_LEAVE", "删除员工", "employeeRemove", true),

    /**
     * 组织关联员工
     */
    ORGANIZATION_ATTACH_EMPLOYEE("MOZI_VDS_TENANT_CHANGE|ORGANIZATION_ATTACH_EMPLOYEE", "组织关联员工", "deptAttachEmployee", true),

    /**
     * 组织取关员工
     */
    ORGANIZATION_DETACH_EMPLOYEE("MOZI_VDS_TENANT_CHANGE|ORGANIZATION_DETACH_EMPLOYEE", "组织取关员工", "deptDetachEmployee", true),

    /**
     * 修改账号名
     */
    CHANGE_ACCOUNT_NAME("MOZI_BUC_ACCOUNT_MODIFY_REALM|change_account_name", "修改账号名", "", false),

    /**
     * 冻结账号
     */
    FROZEN("MOZI_BUC_ACCOUNT_MODIFY_REALM|frozen", "冻结账号", "", false),

    /**
     * 解冻账号
     */
    UNFROZEN("MOZI_BUC_ACCOUNT_MODIFY_REALM|unfrozen", "解冻账号", "", false),

    /**
     * 应用更新
     */
    OPENPLATFORM_APP_UPDATE("OPEN_PLATFORM_CALLBACK|OPENPLATFORM_APP_UPDATE", "应用更新", "", false),

    /**
     * 消息发送成功事件
     */
    SENDSUCCESSMSG("notification_send_event|SendSuccessMsg", "消息发送成功事件", "", false),

    /**
     * 客户端消息回执事件
     */
    SUCCESSACCEPTMSG("notification_client_ack|SuccessAcceptMsg", "客户端消息回执事件", "", false),

    /**
     * 客户端消息回执事件
     */
    FAILED_ACCOUNT_ID("ding_create_event|FAILED_ACCOUNT_ID", "客户端消息回执事件", "", false);

    public final String code;

    public final String name;

    public final String callbackMethod;

    public final Boolean enable;

    EventEnum(String code, String name, String callbackMethod, Boolean enable) {
        this.code = code;
        this.name = name;
        this.callbackMethod = callbackMethod;
        this.enable = enable;
    }

    public static EventEnum format(String code) {
        if (StrUtil.isEmpty(code)) {
            return null;
        }
        for (EventEnum eventEnum : EventEnum.values()) {
            if (StrUtil.equals(eventEnum.code, code)) {
                return eventEnum;
            }
        }
        return null;
    }
}
